package com.gzx.bi.core.utils;

import com.gzx.bi.modular.goals.monthly.entity.vo.GzxCommissionRatioListVo;

import java.math.BigDecimal;
import java.util.List;

/**
 * 获取佣金比例
 */

public class CommissionRatioUtil {


    /**
     * 根据金额获取佣金比例
     * @param money
     * @param list
     * @return
     */
    public static BigDecimal getCommissionRatio(BigDecimal money, List<GzxCommissionRatioListVo> list) {
        for (GzxCommissionRatioListVo gzxCommissionRatioListVo : list) {
            if(money.compareTo(gzxCommissionRatioListVo.getFirst()) >= 0 && money.compareTo(gzxCommissionRatioListVo.getLast()) <= 0){
                return gzxCommissionRatioListVo.getRatio();
            }
        }
        return null;
    }
}
